import { getComponentConfig } from '@/comon/tools';
import { useEditorStore } from '@/store/editor';
import { FC } from 'react';

const NoProp: FC = () => {
  return <div style={{ textAlign: 'center' }}>未选中组件</div>;
};

const PropForm: FC = () => {
  const { selectedComponentInfo } = useEditorStore();

  if (!selectedComponentInfo) {
    return <NoProp />;
  }

  const { type } = selectedComponentInfo;
  const componentConfig = getComponentConfig(type);

  if (!componentConfig) {
    return <NoProp />;
  }

  const { Form } = componentConfig;

  return <Form />;
};

export default PropForm;
